# CMake Generate Executable File.
# Author: Livmee

set(TARGET_NAME fastLib)
# 源文件列表
set(SOURCES
    ${CMAKE_CURRENT_SOURCE_DIR}/utils.cpp
)

set(HEADERS
	${CMAKE_CURRENT_SOURCE_DIR}/include/utils.h
)

# 添加可执行文件
add_library(${TARGET_NAME} STATIC
    ${SOURCES}
    ${HEADERS}
)

# PUBLIC: 当前和关联目标构建时都可见
# PRIVATE: 仅当前目标构建时可见
# INTERFACE: 仅关联目标构建时可见
target_include_directories(${TARGET_NAME}
    PUBLIC
    ${CMAKE_CURRENT_SOURCE_DIR}/include
)

target_link_libraries(${TARGET_NAME}
    PUBLIC
    Qt6::Widgets
    Qt6::Gui
    Qt6::Core
    Qt6::SerialPort
)

# 多配置时为了跨平台兼容
# 配置安装对象(生成对象)
# 用于 XXXConfig.cmake 的导出
# 配置安装位置，动态库 .so
# 配置安装位置，静态库 .a
# 配置安装位置，Windows DLL
install(TARGETS ${TARGET_NAME}
    # EXPORT MyLibTargets
    LIBRARY DESTINATION ${PROJECT_NAME}/lib
    ARCHIVE DESTINATION ${PROJECT_NAME}/lib
    RUNTIME DESTINATION ${PROJECT_NAME}/bin
)

# 配置安装对象(整个目录)
# 配置安装位置，头文件.h
# 安装文件匹配
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include
    DESTINATION ${PROJECT_NAME}
    FILES_MATCHING PATTERN "*.h"      
)